import { BaseEntity } from '@libs/common/entities';
import { Column, Entity, Index } from 'typeorm';

export const PointsWaitType = ['attendance', 'performance'] as const;
export const Status = [0, 1] as const;

export enum PointsWaitTypeEnum {
  '考勤' = 'attendance',
  '绩效' = 'performance',
  'attendance' = '考勤',
  'performance' = '绩效',
}
@Index('dingId_remark', ['dingId', 'remark'], { unique: true })
@Entity('crm_node_market_points_wait')
export class PointsWait extends BaseEntity {
  @Column({ comment: '用户名' })
  userName: string;

  @Column({ comment: '用户ID' })
  userId: string;

  @Column({ comment: '钉钉用户ID' })
  dingId: string;

  @Column({ comment: '部门ID' })
  departmentId: string;

  @Column({ comment: '部门名' })
  departmentName: string;

  @Column({ comment: '积分' })
  points: number;

  @Column({ type: 'enum', enum: PointsWaitType, comment: '类型' })
  type: (typeof PointsWaitType)[number];

  @Column('tinyint', {
    comment: '审核状态，0：未发放，1：已发放',
    default: 0,
  })
  status: (typeof Status)[number] = 0;

  @Column({ comment: '审核人', nullable: true })
  approverName?: string;

  @Column({ comment: '审核ID', nullable: true })
  approverId?: string;
}
